package day1;

public class Demo {
    public static void main(String[] args) {
        //求1到5之间的和
        int sum =0;
        for (int i = 1; i < 6; i++) {
            sum+=i;
        }
        System.out.println("总和为："+sum);



        //求1-100之间的偶数和
        int total = 0;
        for (int i = 1; i < 101; i++) {
            //判断是否为偶数
            if(i % 2 ==0){
                total+=i;
            }
        }
        System.out.println("偶数和为"+total);
          //方法二，修改迭代器中的值
        int total2=0;
        for (int i = 2; i < 101; i+=2) {
            total2+=i;
        }
        System.out.println("偶数和："+total2);
    }
}
